package jl.cts.objects;

import java.util.ArrayList;

import jl.cts.R;
import jl.cts.util.Sprite;
import android.content.Context;

public class Player extends Sprite {

	public Player(Context context, int x, int y) {
		super(context, R.drawable.rabbit2, x, y);

	}

	public boolean isOutOfTheStreetUp(int streetY) {
		if (this.getY() + this.getSpeedY() < streetY) {
			return true;
		} else {
			return false;
		}
	}

	public boolean isOutOfTheStreetDown(int streetY, int streetHeight) {
		if (this.getY() + this.getSpeedY() + this.getHeight() > streetY
				+ streetHeight) {
			return true;
		} else {
			return false;
		}
	}

	public boolean CollidePlayer(ArrayList<Road> roads) {
		boolean collide = false;

		for (Road road : roads) {
			for (Car car : road.getCars()) {
				if (car.isColliding(Player.this)) {
					collide = true;
					break;
				}
			}
			if (collide) {
				break;
			}
		}

		return collide;
	}
}
